<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1> duruigang-swoole-ws 测试</h1>

    <script>
        var wsUrl = "ws://140.143.228.54:8812";

        var websocket = new WebSocket(wsUrl);

        //实例对象的open属性
        websocket.onopen = function (evt) {
            websocket.send("hello-swoole")
            console.log("connected-swoole-success");
        }

        //实例化  onmsessage
        websocket.onmessage = function (evt) {
            console.log("ws-server_return-data:"+evt.data);
        }

        //onclose
        websocket.onclose = function (evt) {
            console.log("ws-close");
        }

        //onerror
        websocket.onerror = function (evt) {
            console.log("error" +evt.data);
        }
    </script>
</body>
</html>